#include "Physical/subStation.h"

//
// Constructors/Destructors
//

/**
 * Empty Constructor
 */
physical::subStation::subStation ( ) : physical::property ( )
{
    initAttributes();
}

/**
 * Constructor
 * @param  lattitude Lattitude of the station.
 * @param  longitude Longitude of the station
 */
physical::subStation::subStation (double lattitude, double longitude) : physical::property (lattitude, longitude)
{
}

/**
 * Destructor
 */
physical::subStation::~subStation ( )
{
    // Remove link between substation and power plant
    this->pwrPlantLink->disconnectAllProperty();
    this->pwrPlantLink = NULL;
    // Remove link between substation and load
    //this->loadLink;
    // Remove link between substation and transmission line
    //this->lineLink;
    // Remove link between substation and local network
    //this->localNetworkLink;
    // Remove link between substation and regional network
    //this->regionalNetworkLink;
}


//
// Methods
//

/**
 * Connects a power plant object to the station (creates pointer from station to
 * power plant object). Returns TRUE if successful, else FALSE.
 * @return bool
 * @param  pwrPlant ptr to power plant object
 */
bool physical::subStation::connectPwrPlant (property* pwrPlantLink)
{
    this->pwrPlantLink = pwrPlantLink;
    return true;
}

/**
 * Disconnects a power plant object to the station (destroys pointer from station
 * to power plant object). Returns TRUE if successful, else FALSE.
 * @return bool
 * @param  pwrPlant Ptr to power plant object.
 */
bool physical::subStation::disconnectPwrPlant ( )
{
    this->pwrPlantLink = NULL;
    return true;
}

/**
 * Connects a load object to the station (creates pointer from station to load
 * object). Returns TRUE if successful, else FALSE.
 * @return bool
 * @param  load ptr to load object
 */
//bool physical::subStation::connectLoad (load* load){}

/**
 * Disconnects a load object to the station (destroys pointer from station to load
 * object). Returns TRUE if successful, else FALSE.
 * @return bool
 * @param  load ptr to load object
 */
//bool physical::subStation::disconnectLoad (load* load){}

/**
 * Connects a transmission line object to the station (creates pointer from station
 * to transmission line object). Returns TRUE if successful, else FALSE.
 * @return bool
 * @param  line
 */
//bool physical::subStation::connectLine (transLine* line){}

/**
 * Disconnects a transmission line object to the station (destroys pointer from
 * station to transmission line object). Returns TRUE if successful, else FALSE.
 * @return bool
 * @param  line ptr to line object
 */
//bool physical::subStation::disconnectLine (transLine* line){}

/**
 * @return bool
 * @param  localNetwork
 */
//bool physical::subStation::joinLocalNet (localNetwork* localNetwork){}

/**
 * @return bool
 */
//bool physical::subStation::quitLocalNet ( ){}

/**
 * @return bool
 * @param  localNetwork
 */
//bool physical::subStation::changeLocalNet (localNetwork* localNetwork){}

/**
 * @return bool
 * @param  regionalNetwork
 */
//bool physical::subStation::joinRegionalNet (regionNetwork* regionalNetwork){}

/**
 * @return bool
 */
//bool physical::subStation::quitRegionalNet ( ){}

/**
 * @return bool
 * @param  regionalNetwork
 */
//bool physical::subStation::changeRegionalNet (regionNetwork* regionalNetwork){}


//
// Accessor methods
//
/**
 * Get the value of SUBSTATION_COUNT
 * @return the value of SUBSTATION_COUNT
 */
unsigned long physical::subStation::getSUBSTATION_COUNT ( )
{
    return subStation::SUBSTATION_COUNT;
}

/**
 * Set the value of numPwrPlants
 * Number of power plants connected to the station.
 * @param new_var the new value of numPwrPlants
 */
void physical::subStation::setNumPwrPlants ( int new_var )
{
    numPwrPlants = new_var;
}

/**
 * Get the value of numPwrPlants
 * Number of power plants connected to the station.
 * @return the value of numPwrPlants
 */
int physical::subStation::getNumPwrPlants ( )
{
    return numPwrPlants;
}

/**
 * Set the value of pwrPlant
 * Pointer to power plant object.
 * @param new_var the new value of pwrPlant
 */
void physical::subStation::setPwrPlant ( physical::property* new_var )
{
    pwrPlantLink = new_var;
}

/**
 * Get the value of pwrPlant
 * Pointer to power plant object.
 * @return the value of pwrPlant
 */
physical::property* physical::subStation::getPwrPlant ( )
{
    return pwrPlantLink;
}

/**
 * Set the value of numLoads
 * Number of loads connected to the station.
 * @param new_var the new value of numLoads
 */
/**
 *void physical::subStation::setNumLoads ( int new_var )
 *{
 *    numLoads = new_var;
 *}
 */
/**
 * Get the value of numLoads
 * Number of loads connected to the station.
 * @return the value of numLoads
 */
/**
 *int physical::subStation::getNumLoads ( )
 *{
 *    return numLoads;
 *}
 */
/**
 * Set the value of load
 * Pointer to the load object.
 * @param new_var the new value of load
 */
/**
 *void physical::subStation::setLoad ( load* new_var )
 *{
 *    load = new_var;
 *}
 */
/**
 * Get the value of load
 * Pointer to the load object.
 * @return the value of load
 */
/**
 *load* physical::subStation::getLoad ( )
 *{
 *    return load;
 *}
 */
/**
 * Set the value of numLines
 * Number of transmittion lines connected to the station.
 * @param new_var the new value of numLines
 */
/**
 *void physical::subStation::setNumLines ( int new_var )
 *{
 *    numLines = new_var;
 *}
 */
/**
 * Get the value of numLines
 * Number of transmittion lines connected to the station.
 * @return the value of numLines
 */
/**
 *int physical::subStation::getNumLines ( )
 *{
 *    return numLines;
 *}
 */
/**
 * Set the value of line
 * Pointer to the transmission line object.
 * @param new_var the new value of line
 */
/**
 *void physical::subStation::setLine ( transLine* new_var )
 *{
 *    line = new_var;
 *}
 */
/**
 * Get the value of line
 * Pointer to the transmission line object.
 * @return the value of line
 */
/**
 *transLine* physical::subStation::subStation::getLine ( )
 *{
 *    return line;
 *}
 */
/**
 * Set the value of localNetwork
 * Pointer to local network object where the station is located.
 * @param new_var the new value of localNetwork
 */
/**
 *void physical::subStation::setLocalNetwork ( localNetwork* new_var )
 *{
 *    localNetwork = new_var;
 *}
 */
/**
 * Get the value of localNetwork
 * Pointer to local network object where the station is located.
 * @return the value of localNetwork
 */
/**
 *localNetwork* physical::subStation::getLocalNetwork ( )
 *{
 *    return localNetwork;
 *}
 */
/**
 * Set the value of regionalNetwork
 * Pointer to regional network object where the station is located.
 * @param new_var the new value of regionalNetwork
 */
/**
 *void physical::subStation::setRegionalNetwork ( regionNetwork* new_var )
 *{
 *    regionalNetwork = new_var;
 *}
 */
/**
 * Get the value of regionalNetwork
 * Pointer to regional network object where the station is located.
 * @return the value of regionalNetwork
 */
/**
 *regionNetwork* physical::subStation::getRegionalNetwork ( )
 *{
 *    return regionalNetwork;
 *}
 */
/**
 * Set the value of uniqueStationID
 * @param new_var the new value of uniqueStationID
 */
void physical::subStation::setUniqueStationID ( unsigned long new_var )
{
    uniqueStationID = new_var;
}

/**
 * Get the value of uniqueStationID
 * @return the value of uniqueStationID
 */
unsigned long physical::subStation::getUniqueStationID ( )
{
    return uniqueStationID;
}


//
// Other methods
//
void physical::subStation::initAttributes ( ) {
    numPwrPlants = 0;
    pwrPlantLink = NULL;
    //numLoads = 0;
    //loadLink = NULL;
    //numLines = 0;
    //lineLink = NULL;
    //localNetworkLink = NULL;
    //regionalNetworkLink = NULL;
    uniqueStationID = SUBSTATION_COUNT++;
}
